import {Column, CreateDateColumn, Entity, PrimaryGeneratedColumn, UpdateDateColumn} from "typeorm";
import {ApiProperty} from "@nestjs/swagger";

@Entity('sys_blogs')
export class BlogEntity {
	@PrimaryGeneratedColumn({ type: 'bigint' })
	id: number

	@Column({ type: 'longtext', name: 'blog_content', comment: '博客内容' })
	blogContent: string

	@Column({ type: 'boolean', name: 'enable',default:true, comment: '是否可用' })
	enable: boolean

	@Column({ type: 'longtext', name: 'blog_title', comment: '文章标题' })
	blogTitle: string

	@Column({ type: 'int', name: 'blog_type',default: 1, comment: '文章类型： 1-新闻趣事 2-博客文章' })
	blogType: number

	@Column({ type: 'varchar',length:200, name: 'blog_desc', comment: '文章描述' })
	blogDesc: string

	@Column({ type: 'varchar',length:500, name: 'cover_url', comment: '文章封面图片' })
	coverUrl: string

	@Column({ type: 'tinyint', name: 'editor_type',default:1, comment: '编辑器类型' })
	editorType: 1|2

	@CreateDateColumn({ type: 'timestamp', name: 'create_date', comment: '创建时间',
		precision: 0,default:()=>'CURRENT_TIMESTAMP(0)'})
	@ApiProperty({ description: '创建时间' })
	createDate: Date

	@UpdateDateColumn({ type: 'timestamp', name: 'update_date', comment: '更新时间',
		precision: 0,default:()=>'CURRENT_TIMESTAMP(0)',onUpdate:'CURRENT_TIMESTAMP'
	})
	@ApiProperty({ description: '更新时间' })
	updateDate: Date
}
